<?php

class Zend_Form_Decorator_StarDecorator extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return $content . '<span style="color:red"> *</span>';
	}
}
class Zend_Form_Decorator_StarDecoratorForState extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return $content . '<span id="StarDecoratorForState" style="color:red"> *</span>' /*: $content */;
	}
}
class Zend_Form_Decorator_StarDecoratorForStateInvisible extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return $content . '<span id="StarDecoratorForState" style="color:red;display:none"> *</span>' /*: $content */;
	}
}

class StarDecorator extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return /*($this ->getElement()-> isRequired()) ?*/$content . '<span style="color:red"> *</span>' /*: $content */;
	}
}
class StarDecoratorForState extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return $content . '<span class="StarDecoratorForState" style="color:red"> *</span>' /*: $content */;
	}
}
class StarDecoratorForStateInvisible extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return $content . '<span class="StarDecoratorForState" style="color:red;display:none"> *</span>' /*: $content */;
	}
}

class CaptchaClassDecorator extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return '<span class="captcha">' . $content . '</span>';
	}
}

class PerOneItemDecorator extends Zend_Form_Decorator_Abstract {
	var $perOneItem;
	
	public function __construct($perOneItem = "") {
		parent::__construct ();
		$this->perOneItem = $perOneItem;
	}
	
	public function render($content) {
		return $content . ' <span style="font-size:12px"><i> (' . $this->perOneItem . ')</i></span>';
	}
}

class CurrencyDecorator extends Zend_Form_Decorator_Abstract {
	var $perOneItem;
	
	public function __construct($perOneItem = "") {
		parent::__construct ();
		$this->perOneItem = $perOneItem;
	}
	
	public function render($content) {
		
		$api = Zend_Registry::get ( 'api' );
		return $content . ' <span style="font-size:12px"><b>' . $api->Currency->Code . '</b><i> (' . $this->perOneItem . ')</i></span>';
	}
}

class MessangerDecorator extends Zend_Form_Decorator_Abstract {
	var $value;
	
	public function __construct($value = "") {
		parent::__construct ();
		$this->value = $value;
	}
	
	public function render($content) {
		return $content . '&nbsp;&nbsp;<input type="text" name="messanger_value" id="messanger_value" value="' . $this->value . '" />';
	}
}

class DoublePasswordDecorator extends Zend_Form_Decorator_Abstract {
	public function render($content) {
		return $content . '&nbsp;&nbsp;<input type="password" name="confirmpassword" id="confirmpassword" value="" />';
	}
}

class RegisterNowDecorator extends Zend_Form_Decorator_Abstract {
	var $label;
	
	public function __construct($label = "") {
		parent::__construct ();
		$this->label = $label;
	}
	
	public function render($content) {
		if ($this->label) {
			return '<tr><td>&nbsp;</td><td>' . $content . '<input type="checkbox" value="1" id="registerNow" name="registerNow"><label id="registerNowLabel" class="optional" for="registerNow">' . $this->label . '</label></td></tr>';
		} else {
			return '<tr><td>&nbsp;</td><td>' . $content . '</td></tr>';
		}
	}
}

class SupplementalContactsDecorator extends Zend_Form_Decorator_Abstract {
	private $SupplementalContactsText;
	private $marginTop;
	private $marginBottom;
	
	public function __construct($text = '', $marginTop = '40', $marginBottom = '10') {
		parent::__construct ();
		$this->SupplementalContactsText = $text;
		$this->marginTop = $marginTop;
		$this->marginBottom = $marginBottom;
	}
	
	public function render($content) {
		return '<dt style="width:100%; text-align:left; margin:' . $this->marginTop . 'px 0 ' . $this->marginBottom . 'px 0;"><b>' . $this->SupplementalContactsText . ':</b></dt>' . $content;
	}
}

class SupplementalFirstDecorator extends Zend_Form_Decorator_Abstract {
	var $Pixels = '10';
	public function __construct($Pixels = '10') {
		parent::__construct ();
		$this->Pixels = $Pixels;
	}
	
	public function render($content) {
		return '<div style="margin-top: ' . $this->Pixels . 'px;">' . $content . '</div>';
	}
}

class UneditableTextDecorator extends Zend_Form_Decorator_Abstract {
	var $Pixels = '10';
	public function render($content) {
		// TODO: eliminate any design specific from the code!!!
		//       Use separate class for each element on form
		$val = '<b  style="line-height:18px">' . $this->getElement ()->getValue () . '&nbsp;</b>';
		$val .= '<input type="hidden" id="' . $this->getElement ()->getId () . '" name="' . $this->getElement ()->getId () . '" value="' . $this->getElement ()->getValue () . '" />';
		return $val;
	}
}

class BottomButtonDecorator extends Zend_Form_Decorator_Abstract {
	var $useDottedLine = false;
	var $additionalButtons = array ();
	var $buttonHelper = array ();
	var $useDdWrapping = true;
	
	public function __construct($useDottedLine = false, $additionalButtons = array(), $buttonHelper = null, $useDdWrapping = true) {
		parent::__construct ();
		$this->useDottedLine = $useDottedLine;
		$this->additionalButtons = $additionalButtons;
		$this->buttonHelper = $buttonHelper;
		$this->useDdWrapping = $useDdWrapping;
	}
	
	public function render($content) {
		$content = '<div style="float: right;">' . $content . '</div>';
		$additionalButtonsHtml = '';
		foreach ( $this->additionalButtons as $name => $button ) {
			
			if (is_array ( $button )) {
				$onclick = array_key_exists ( 'onclick', $button ) ? $button ['onclick'] : '';
				$id = array_key_exists ( 'id', $button ) ? $button ['id'] : '';
				$class = array_key_exists ( 'class', $button ) ? $button ['class'] : '';
				$type = array_key_exists ( 'type', $button ) ? $button ['type'] : 'orange';
			} else {
				$onclick = $button;
				$id = '';
				$class = '';
				$type = 'orange';
			}
			
			if (is_object ( $this->buttonHelper )) {
				$additionalButtonsHtml = $this->buttonHelper->coreButton ( $name, $onclick, $id, $class, $type ) . $additionalButtonsHtml;
			} else {
				$additionalButtonsHtml = '<button onclick="' . $onclick . '" >' . $name . '</button>' . $additionalButtonsHtml;
			}
		}
		if ($additionalButtonsHtml != '') {
			$content .= '<div style="float:left;">' . $additionalButtonsHtml . '</div>';
		}
		$content = '<div style="margin-top: 20px;height:25px" class="bottom-buttons top-dotted">' . $content . '</div>';
		if ($this->useDdWrapping) {
			$content = '<dd style="margin:0">' . $content . '</dd>';
		}
		return $content;
	}
}

?>
